<template>
  <div class="mod-config">
    <div class="z-querybar">
      <el-date-picker v-model="dataForm.daterange" style="width: 250px;" align="center" :clearable="false" @change="getDataList"
        type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
      </el-date-picker>
      <z-search-btn @click="currentChangeHandle(1)"></z-search-btn>
      <z-export-btn @click="exportDataList()"></z-export-btn>
      <!-- <el-button type="primary" @click="dataExport()">
        导出数据
      </el-button> -->
    </div>
    <div class="z-pagecontent">
      <el-table :data="dataList" border stripe v-loading="dataListLoading" style="width: 100%;" :height="maxHeight">
        <el-table-column type="index" header-align="center" label="序号" align="center" width="50">
        </el-table-column>
        <el-table-column prop="numberPlate" header-align="center" align="center" label="车牌号" min-width="130" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="syWeight" header-align="center" align="center" label="收运总量" min-width="80" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="lostTime" header-align="center" align="center" label="收运总耗时(秒)" min-width="80" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="taskCount" header-align="center" align="center" label="收运任务数量" min-width="80" show-overflow-tooltip>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { formatDate } from '@/utils/timeUtils'
export default {
  name: "collReport",
  data() {
    const now = new Date()
    const pre = new Date(now.getTime() - 3600000 * 24 * 30)
    return {
      maxHeight: document.documentElement.clientHeight - 260,
      //搜索条件
      dataForm: {
        daterange: [pre, now]
      },
      curPage: 1,
      pageSize: 10,
      totalPage: 0,
      pageIndex:1,
      dataList: [],
      dataListLoading: false
    };
  },
  mounted() {
    this.getDataList();
  },
  methods: {
    //数据渲染
    getDataList() {
       this.$http({
        url: this.$http.adornUrl('/sign/signtask/weightTotalGroupByCar'),
        method: 'post',
        data: this.$http.adornData({
          'startTime': formatDate(this.dataForm.daterange[0], 'yyyy-MM-dd 00:00:00'),
          'endTime': formatDate(this.dataForm.daterange[1], 'yyyy-MM-dd 23:59:59'),
          'order': '2'
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.list
        } else {
          this.dataList = []
        }
      })
    },
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    //导出数据
    exportDataList() {
      const startTime = formatDate(this.dataForm.daterange[0], 'yyyy-MM-dd')
      const endTime = formatDate(this.dataForm.daterange[1], 'yyyy-MM-dd')
      this.$http({
        url: this.$http.adornUrl('/sign/signtask/weightTotalGroupByCar'),
        method: 'post',
        data: this.$http.adornData({
          'startTime': startTime + ' 00:00:00',
          'endTime': endTime + ' 23:59:59',
          'order': '2'
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          const col = [
            { label: '车牌号', prop: 'numberPlate' },
            { label: '收运总量', prop: 'syWeight' },
            { label: '收运总耗时(秒)', prop: 'lostTime' },
            { label: '收运任务数量', prop: 'taskCount' }
          ]
          let name = '车辆收运统计[' + startTime + '至' + endTime + ']'
          this.JSONToExcelConvertor(col, data.list, name)
        }
      })
    }
  }
};
</script>

<style scoped lang='scss'>
@mixin inputLocation($width: 220px, $inputWidth: 180px) {
    width: $width;
    display: flex;
    align-items: center;
    justify-content: center;

    & > p {
        font-size: 13px;
        line-height: $conditionHeight;
        margin-right: 10px;
    }
    .input {
        width: $inputWidth;
    }
}
$themeColor: #00284d;
$themeLight: #2bffff;
$fontColor: #fff;

$font32: 32px;
$black: #000000;

$containerTop: 80px;
$topHeight: 60px;
$conditionHeight: 32px; //表格上方条件的高度

#manage {
    font-family: PingFang SC;
    position: relative;
    height: 100%;
    .condition{
      display: flex;
      width: 100%;
      align-items: center;
    }
}
.firstInput {
  @include inputLocation(260px);
}
.secondInput {
  @include inputLocation(260px);
}
.searchBtn {
  width: 20%;
  float: left;
}
</style>
<style lang='scss'>
.summary {
  width: 100%;
  height: 15%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 1);
  margin: 0 auto;
  .el-divider--vertical {
    margin: 0 2px !important;
  }
}
.tableDiv {
  width: 100%;
  margin-top: 1%;
  background: rgba(255, 255, 255, 1);
  .condition {
    width: 100%;
    height: 10.5%;
    padding-left: 3%;
    padding-top: 1%;
  }
  .table {
    width: 100%;
    height: auto;
  }
}
.summaryItem {
  width: 23%;
  height: 100px;
  line-height: 100px;
  display: flex;
  // align-items: center;
  .itemText {
    font-size: 15px;
    margin-left: 12px;
    font-family: PingFangSC;
    font-weight: 400;
    color: rgba(68, 68, 68, 1);
    width: 118px;
    height: 16px;
  }
  .itemNum {
    width: 34px;
    height: 18px;
    font-size: 23px;
    font-family: DINPro;
    font-weight: 500;
    color: rgba(37, 43, 58, 1);
    margin-left: 10px;
  }
}
.iconfont {
  width: 30px;
  height: 30px;
  color: #167fff;
}
</style>
